home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: Intraprocess piping into an array
- Followup-To: comp.unix.programmer
- Date: Sun, 07 Apr 96 18:30:31 GMT
- Organization: none
- Message-ID: <828901831snz@genesis.demon.co.uk>
- References: <4k6r1p$eoh@news.tiac.net>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4k6r1p$eoh@news.tiac.net> craigm@max.tiac.net "Craig Mattson" writes:
-
- >I'd like to pipe stdout into an array so I can process it before
- >it actually gets printed. However, I don't want to fork a process
- >just to read the array as it's being output. Here's what I've been
- >trying to do, which works until the output gets too large:
-
- You're talking about thinks like fork, pipe, close, dup, fdopen which are
- not defined by the C language. They are system calls defined by Unix and
- should be discussed in comp.unix.programmer.
-
- >The problem is that the fflush() tries to flush the _whole_ buffer,
- >which is often too large for the standard buffer size for the read end
- >of the pipe.
-
- No reads are involved at the time you call fflush(stdout) so the read
- buffer size is not relevant. Make sure the pipe is empty before you call
- fflush() and the write buffer size is less than the pipe buffer size (often
- about 4K), although the real issue is to ensure that you haven't written
- more than the pipe buffer size between reads, which is what will lock you
- up. Followups to comp.unix.programmer.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-